/*  ----------------------------------------------------------------------------
 *  Arello Mobile
 *  Fast 3d Engine
 *  ----------------------------------------------------------------------------
 * Except where otherwise noted, this work is licensed under
 * http://creativecommons.org/licenses/by/3.0
 */

#include "TextureRenderTarget.h"
#include <xml/Stream.h>
#include <safe_new.h>

namespace liba
{
namespace lib3d
{
namespace material
{

bool TextureRenderTargetName::on_attribute( xml::Provider * prov, const std::string & name, const std::string & value )
{
	if( name == "Name" )
		return converter::convert( value, &render_target_name );
	if( name == "Wrap" )
		return converter::convert( value, &wrap );
	return false;
}

bool TextureRenderTargetName::operator<( const TextureRenderTargetName & na )const
{
	return render_target_name < na.render_target_name;
}

void TextureRenderTarget::render_to_list( hard::Hardware * hardware, hard::RenderTexture * render_texture )
{
	render_texture->texture = hardware->get_render_target( render_target_name );
}

TextureRenderTarget * TextureRenderTarget::clone()const
{
	return new TextureRenderTarget(*this);
}

} // namespace material
} // namespace lib3d
} // namespace liba

